fix: correct pinned maps handling and implement missing userspace setup#13
Open
SiyuanSun0736 wants to merge 1 commit intomultikernel:mainfrom
Open
fix: correct pinned maps handling and implement missing userspace setup#13SiyuanSun0736 wants to merge 1 commit intomultikernel:mainfrom
SiyuanSun0736 wants to merge 1 commit intomultikernel:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes critical issues in the
pinkeyword implementation for map declarations. Previously, pinned maps were incorrectly treated as global variables, leading to runtime failures. Additionally, this PR introduces a robust userspace setup including automatic directory creation and unique variable naming.Problems Addressed
__pinned_globalsmap, resulting in:Failed to find pinned globals map in eBPF object.existing_fd) for all map instances./sys/fs/bpf/did not already exist.Implementation Details (Before vs. After)
1. Fixing Incorrect Map Handling
Before: The generator erroneously looked for a
__pinned_globalsmap for any pinned variable.After: Directly handles the specific map and ensures the BPF file system path is ready.
2. Robust Directory Creation
Added
ensure_bpf_dirC helper function to recursively create paths (e.g.,/sys/fs/bpf/<project>/maps/) before pinning, preventing "No such file or directory" errors.Proposed Changes
ir_generator.ml): Modified to ensure map-type global declarations only produce map definitions, preventing redundant global variable entries.userspace_codegen.ml):has_pinned_mapsis detected.%s_existing_fd) to support multiple pinned maps.ensure_bpf_dirhelper and required headers (<sys/stat.h>,<sys/types.h>).Verification Results
examples/maps_demo.ks__pinned_globalslookup error./sys/fs/bpf/maps_demo/maps/.